#ifndef __SERIAL_H__
#define __SERIAL_H__


#ifdef __cplusplus
extern "C" {
#endif

#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<termios.h>
#include<fcntl.h>
#include<errno.h>
//#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<unistd.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<termios.h>
#include<fcntl.h>
#include<errno.h>

#define TRUE 1
#define FALSE -1
#define BUFF_MAXSIZE 2048

typedef unsigned char un_char;

//初始化设置，即设置通信协议
int OpenDev(char *dev);//打开串口设备文件
int Set_speed(int fd,int speed,struct termios *newtio);//设置波特率
int Set_attr(int fd,int databits,int stopbits,char parity,int flow_ctrl,int cmin,int times);

//数据读写函数
int Write_Data(int fd, void *buf, size_t data_len);//发送命令代码函数
int Read_Data(int fd,un_char *buff,size_t data_len,unsigned int timeout_millisec);

//数据处理
void Data_Processing(un_char *buff,size_t data_len,double a[4],double w[4],double h[4],double Angle[4],double Port[4],double TPA[3]);

#ifdef __cplusplus
}
#endif


#endif /* __SERIAL_H__ */
